<%@ page language="java" contentType="text/html;charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<div class="page-header">
    <h3 style="margin-top: auto">项目类别</h3>
</div>
<div class="row-fluid">
    <table class="table table-hover">
    <thead>
        <tr>
            <th>#</th>
            <th>名称</th>
            <th>中文名称</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${pgroups}" var="pgroup" varStatus="status">
            <tr>
                <td>${status.count}</td>
                <td>${pgroup.name}</td>
                <td>${pgroup.cnName}</td>
                <td>
                    <div class="btn-group">
                        <button class="btn"  onclick="showPGroupInfo('${pgroup.description}')" >
                            <i class="icon-search"></i>&nbsp;详细信息
                        </button>
                        <button class="btn"
                            onclick="window.location.href='<%=request.getContextPath()%>/pgroup/${pgroup.id}/add_member';">
                            <i class="icon-edit"></i>&nbsp;成员管理
                        </button>
                        <button class="btn" onclick="showDeletePanel(${pgroup.id}, this)">
                            <i class="icon-trash"></i>&nbsp;删除
                        </button>
                    </div>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>

</div>

<div class="modal hide fade" id="delete-pgroup-panel">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"
            aria-hidden="true">&times;</button>
        <h3>删除项目组</h3>
    </div>
    <div class="modal-body">
        <p>确定要删除项目组?</p>
    </div>
    <div class="modal-footer">
        <!-- button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button-->
        <button class="btn" data-dismiss="modal" id="delete-pgroup-btn">
            <i class="icon-ok"></i>&nbsp;确定
        </button>
        <button class="btn" data-dismiss="modal">
            <i class="icon-remove"></i>&nbsp;取消
        </button>
    </div>
</div>

<div class="modal hide fade" id="pgroup-info-panel">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"
            aria-hidden="true">&times;</button>
        <h3>项目类别详细信息</h3>
    </div>
    <div class="modal-body">
        <p id="pgroup-info"></p>
    </div>
    <div class="modal-footer">
        <!-- button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button-->
        <button class="btn" data-dismiss="modal" onclick="">
            <i class="icon-ok"></i>&nbsp;确定
        </button>
    </div>
</div>

<script type="text/javascript">
    function deletePGroup(pgroupId, deleteBtn) {
         $.ajax({
        	   url : '/ManEnv/pgroup/' + pgroupId + '/delete',
        	   type : 'DELETE',
        	   success : function(data) {
        		    if (data.result == "true") {
        		    	 alert("删除成功!");
        		    	 $(deleteBtn).parents("tr").remove(); // 删除第一个tr元素
        		    } else {
        		    	 alert("删除失败!");
        		    }
        	   }
		});
	}
    
    function showDeletePanel(groupId, deleteBtn){
        $("#delete-pgroup-panel").modal({
            "show" : true,
            "backdrop" : false
        });
        $("#delete-pgroup-btn").click(function(){
        	deletePGroup(groupId, deleteBtn);
        });
    }
    
    

	function showPGroupInfo(data) {
		$("#pgroup-info").html(data);
		$("#pgroup-info-panel").modal({
			"show" : true,
			"backdrop" : false
		});
	}
</script>

<!-- Le javascript
    ================================================== -->
<!-- Placed at the end of the document so the pages load faster -->

